$(function() {
	$(".upload").click(function() {
		upload();
	});
	$(".download").click(function() {
		download();
	});
});

// ================================模板下载=============================
function download() {
	var form = $("<form></form>");// 定义一个form表单
	form.attr("style", "display:none");
	form.attr("target", "");
	form.attr("method", "post");
	form.attr("action", rootPath + "/ui/partBaseInfo/downloadMb");
	$("body").append(form);// 将表单放置在web中
	form.submit();// 表单提交
	form.remove();
};
// ================================批量上传=============================
function upload() {

	var fileName = $("#partBaseInfoFile").val();
	var len = fileName.lastIndexOf(".");
	var fn = fileName.substring(len, fileName.length);
	if (fileName == "") {
		message("请选中要上传的正确格式的EXCEL文件!");
	} else {
		if (fn == ".xls" || fn == ".xlsx") {
			// 文件上传
			$.ajaxFileUpload({
				url : window.rootPath + "/ui/partBaseInfo/uploadMb",
				secureuri : false,// 是否需要安全协议
				fileElementId : 'partBaseInfoFile',// 文件上传的Id属性
				dataType : 'json',
				success : function(result) {
					alert(result.data.msg);
				}
			});
		} else {
			message("请选中要上传的正确格式的EXCEL文件!");
		}
	}
};